clear
T = readtable('choices_and_prices.csv');

ID = table2array(T(:,1));
dataset = T(:,2:end);

e_lb = zeros(size(dataset,1),1);
e_ub = ones(size(dataset,1),1);
epsilons = .5*ones(size(dataset,1),1);

% compute TMI EU for actual data
tic
for n = 1:14
	evalc('boole = system_has_solution(dataset,epsilons,50,25,true)');

	e_lb(boole==0) = epsilons(boole==0); % didn't find solution for given epsilon --> expected utility TMI is at least that epsilon
	e_ub(boole==1) = epsilons(boole==1); % found solution for given epsilon --> expected utility TMI is at most that epsilon

    epsilons(ismember(boole,[0,-1])) = epsilons(ismember(boole,[0,-1])) + 2^(-(n+1)); % note: increase also if not clear whether a solution exists (boole==-1)
	epsilons(boole==1) = epsilons(boole==1) - 2^(-(n+1));
    
    sprintf('iteration number %d',n)
    tabulate(epsilons)
end
writetable(array2table([ID e_lb e_ub]), 'epsilons.csv');
toc


